class TopicInput {
  constructor(onTopicChange) {
    this.input = document.createElement('input');
    this.onTopicChange = onTopicChange;
    this.setupEventListeners();
  }

  setupEventListeners() {
    this.input.addEventListener('input', (e) => {
      this.onTopicChange(e.target.value);
    });
  }

  render() {
    this.input.type = 'text';
    this.input.placeholder = '输入辩论话题...';
    this.input.classList.add('topic-input');
    return this.input;
  }

  clear() {
    this.input.value = '';
  }

  getCurrentTopic() {
    return this.input.value.trim();
  }
}

export default TopicInput;
